<!DOCTYPE html>
<html>

<head>
	<title></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<link rel="stylesheet" href="../res/css/weui.css" />
	<link rel="stylesheet" href="../res/css/weuix.css" />
	<link rel="stylesheet" href="../res//css/common.css">
	<link rel="stylesheet" href="../res/css/swiper.css">
	<script src="../res/js/zepto.min.js"></script>
	<script src="../res/js/zepto.weui.js"></script>
	<script src="../res/js/common.js?v=1"></script>
	<script src="../res/js/swiper.js"></script>
	<script src="../res/js/socket.js"></script>
	<script src="../res/js/consultationWebsocket.js"></script>
	<style>
		.weui-header .weui-header-title,
		.weui-header h1 {
			margin: 0 40px;
		}

		.swiper-slide {
			height: 175px;
		}

		/* .img-wrapper {
			box-sizing: border-box;
			float: left;
			display: inline-block;
			display: inline-flex;
			align-items: center;
			border-radius: 50%;
			width: 4rem;
			height: 4rem;
			overflow: hidden;
			padding: 0.1rem;
			margin: 0.2rem 0.25rem;
		} */

		.weui-search-bar {
			padding: 8px 10px 0px;
		}

		.img-wrapper>img {
			border-radius: 50%;
		}

		.weui-grid:after {
			content: none;
		}

		.weui-grids:after {
			content: none;
		}

		.weui-cells {
			font-size: 14px;
			margin: 5px 10px;
		}

		.index_title {
			margin: 10px 0;
			margin-top: 0;
			padding: 0 5px;
			font-size: 16px;
			font-weight: bold;
			position: relative;
		}

		.index_title span {
			font-size: 13px;
			font-weight: normal;
		}

		#round1 {
			width: 8px;
			height: 8px;
			background-color: #F8B551;
			color: white;
			position: absolute;
			top: 0;
			border-radius: 6px;
			z-index: -1;
		}

		#round2 {
			width: 13px;
			height: 13px;
			background-color: #1189FF;
			color: white;
			position: absolute;
			top: 7px;
			left: 63px;
			border-radius: 16px;
			z-index: -1;
		}

		.index_con {
			padding: 0 15px;
			color: #666666;
		}

		.index_head {
			text-align: left;
			color: #000000;
		}

		.weui-label-s {
			padding: 9px;
			border: 1px solid #DDDDDD;
			border-radius: 4px;
		}

		.toLists {
			background-color: #0066FF;
			color: #ffffff;
			text-align: center;
			width: 30%;
			margin-left: 33%;
		}

		#seleList{
			display: grid;
    		grid-template-columns: repeat(4, 25%);
		}

		.weui-grids .changeList {
			padding: 5px 5px;
			text-align: center;
			font-size: 13px;
		}

		.weui-grids .changeList a {
			color: #333333;
		}

		.weui-grids .changeList:after {
			border-bottom: 0px;
		}

		.sra:after {
			content: " ";
			display: inline-block;
			height: 6px;
			width: 6px;
			border-width: 2px 2px 0 0;
			border-color: #C8C8CD;
			border-style: solid;
			-webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
			transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
			position: absolute;
			top: 50%;
			margin-top: -3px;
			margin-right: 5px;
			right: 2px;
		}

		/* 医生列表(格子) */

		.weui-grid__icon {
			width: 3rem;
			height: 3rem;
			border-radius: 8rem;
			overflow: hidden;
		}

		.istype {
			position: relative;
			top: -0.8rem;
			width: 100%;
			text-align: center;
			font-size: 12px;
			color: white;
			height: 30px;
			background: rgba(0, 0, 0, .5);
		}

		.weui-grids:before {
			border-top: 0px;
		}

		.weui-grid:before {
			border-right: 0px;
		}

		.weui-cell-border {
			border-bottom: 1px solid #EEEEEE
		}

		.fixed-top {
			border-bottom: 1px solid #e8e8e8;
			position: fixed;
			left: 0;
			top: 0;
			right: 0;
			z-index: 99;
			background: #F6F6F9
		}

		.seldoc {
			padding: 10px;
		}

		.swiper-container img {
			width: 100%;
			height: 100%;
		}

		.swiper-container {
			margin: 10px;
			border-radius: 10px;
			touch-action: none;
		}

		.header_btn {
			margin: 5px 10px;
			display: grid;
			grid-template-columns: 1.6fr 1fr 1fr;
			gap: 10px;
			grid-template-areas: 'a b c'
								 'a d e';
		}

		/* 暖禾需求 隐藏部分入口*/
		.some-hide{
			grid-template-columns: repeat(3, 1fr);
		}

		#my_consult{
			grid-row: 1 / span 2;
		}

		.self_invoicing {
			width: 100%;
			height: 100%;
			background: linear-gradient(to right bottom, #48A4FF, #3E80FA);
			border-radius: 16px;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}

		.self_invoicing p {
			color: #ffffff;
		}

		.header_btn > div img {
			vertical-align: middle;
		}

		.iconfont {
			width: 56px;
			height: 56px;
			margin: 0 auto;
			display: block;
			color: #333333;
		}

		.swiper-pagination-bullet {
			background: white;
			opacity: 0.8;
		}

		.swiper-pagination-bullet-active {
			background: #0066FF;
		}

		.expertlist_map {
			margin: 0;
			margin-bottom: 10px;
		}

		.weui-dialog {
			border-radius: 12px;
		}

		.feeInfoDate span {
			color: #1189FF;
		}

		#start {
			background-color: #ECF6FF;
			height: 40px;
			line-height: 30px;
			margin-top: 10px;
			border-radius: 10px;
		}

		#start span {
			background-color: #1189ff;
			color: #ffffff;
			margin: 0 5px;
			margin-top: 5px;
			width: 30px;
			height: 30px;
			display: inline-block;
			border-radius: 5px;
		}

		#androidDialog1 .weui-mask {
			z-index: 2000;
		}

		.home_icon_img div {
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		#doctorList {
			/* width: 92vw; */
			margin-bottom: 50px;
		}

		#unreadIcon {
			height: 8px;
			width: 8px;
			background-color: red;
			border-radius: 50%;
			position: absolute;
			right: 40px;
		}
	</style>
	<script>
		var CODE = '',
			haveFeeDoctorName = '',
			haveFeeLogType = 0;
		var haveFee = 0,
			fee_pay = 0,
			EndTime = '',
			h5token = '',
			userid = '',
			usertype = '';
		//医院名称
		var hospitalName = "";
		//问诊消息未读小红点
		var msgIsRead = 0;
		// 默认科室图片 科室图片缺少使用
		var defaultDepartment = '../res/images/icon_whole.png'

		//tabbar跳转
		function tabbargo(openid, orgid) {
			$('.weui-tabbar__item').on('click', function () {
				var type = $(this).attr("id");
				console.log(type);
				if (type == "inquiry_index") {
					location.href = "inquiry_doctor_index.htm?orgid=" + orgid + "&openid=" + openid
				} else if (type == "inquiry_doctor") {
					if (!isLogin()) {
						$.confirm("请先登录再操作", function () {
							goPage('login.htm');
						}, function () {
							//取消操作
						});
					} else {
						location.href = "inquiry_doctor.htm?orgid=" + orgid + "&openid=" + openid
					}
				} else if (type == "my_doctor_index") {
					if (!isLogin()) {
						$.confirm("请先登录再操作", function () {
							goPage('login.htm');
						}, function () {
							//取消操作
						});
					} else {
						location.href = "my_doctor_index.htm?orgid=" + orgid + "&openid=" + openid
					}
				} else {
					location.href = "inquiry_user_personal.htm?orgid=" + orgid + "&openid=" + openid;
				}
			});
		}

		function strToJson(jsonStr) {
			return eval('(' + jsonStr + ')');
		}

		function jsonToStr(jsonObj) {
			return JSON.stringify(jsonObj);
		}

		/*将用户数据存储到LocalStorage中*/
		function setUserLocalStorage(userJson) {
			localStorage.setItem("DSXBuserJson", userJson);
		}

		/*从cookie中得到一条userjson 数据*/
		function getUserLocalStorage() {
			var userJson = $("#DSXBuserJson").val();
			if (isUndefinedAndEmpty(userJson)) {
				return {};
			}
			return strToJson(userJson);
		}
		//	轮播图
		function swpier() {
			var mySwiper = new Swiper('.swiper-container', {
				loop: true,
				autoplay: true,
				pagination: {
					el: '.swiper-pagination',
				}
			})
		}


		function isUndefinedAndEmpty(obj) {
			obj = $.trim(obj);
			if (undefined == obj || "undefined" == obj || "" == obj || null == obj) {
				return true;
			}
			return false;
		}

		/*判断当前用户是否已经登录*/
		// function isLogin() {
		//     var userJson = $("#DSXBuserJson").val();
		//     if (isUndefinedAndEmpty(userJson) || userJson == "{}") {
		//         return false;
		//     }
		//     return true;
		// }

		// -----------------3.30
		var openid = getQst("openid").trim();
		var orgid = getQst("orgid").trim();

		//获取首页消息
		// function getActivity() {
		// 	newAjaxPost("/h5/home/getActivity", {}, (json) => {
		// 		console.log(json);
		// 	})
		// }
		//
		// function getConstitution() {
		// 	newAjaxPost("/h5/home/getConstitution", {}, (json) => {
				// console.log(json);
		// 	})
		// }
		//获取医院名称
		function getConfigureName() {
			newAjaxPost("/h5/banner/getConfigureName", {}, (json) => {
				hospitalName = json.data.hospitalNameApp;
				$(".weui-header-title").text(hospitalName)
			})
		}
		$(function () {
			// 导航栏跳转
			tabbargo(openid, orgid)
			// -----------------3.30
			newGetBannerList()

			// 暖禾 隐藏部分入口
			if(!isNuanHe){
				newGetDepartmentList()
			}else{
				$("#my_consult").hide()
				$("#expert_clinic").hide()
				$(".header_btn").addClass('some-hide')
			}
			isFreeBilling ? $(".consult_img").hide() : $(".self_invoicing").hide()

			newGetConsultationFee()
			// getActivity()
			// getConstitution()
			getConfigureName()

			isChengDu ? $("#searchBar").hide() : $("#user-name").hide()
			console.log(isLogin())
			if (isLogin()) {
				newAjaxPost("/h5/userInfo/userInfo", {}, (e) => {
					$('#userName').text(`您好！${e.data.userNickname || ''}`)
				});
			}
			// 轮播图
			swpier()
			//问诊
			var log_type = '';
			var doctor_id = '';
			newGetHomeDoctorList()

			//我的医生未读消息小红点显示
			wsConnection.onMessage = function (msg) {
				if (msg.packageType == 40) {
					// console.log(msg.isRead);
					//是否有未读消息0为不显示1为显示
					msgIsRead = msg.isRead
					if (msgIsRead == 0) {

					} else {
						$("#unreadIcon").show()
					}
				}
				else if(msg.packageType == 7 && (msg.inquiryType == '1' || msg.inquiryType == '2')){
					sessionStorage.setItem('TRTCset', jsonToStr(msg.tencentConfig))
					let log_id = msg.logId,
						log_type = msg.inquiryType,
						doctor_id = msg.inquiryPatientInfoResp.doctorId,
						doctor_imid = msg.inquiryPatientInfoResp.doctorIM,
						patientId = msg.inquiryPatientInfoResp.id,
						patientImId = msg.inquiryPatientInfoResp.patientIM

					console.log('重连问诊 >>>>>>>>>>')
					outOfIFrame(`chat.htm?
						isChatWait=0&doctor_imid=${doctor_imid}&log_id=${log_id}&doctor_id=${doctor_id}&log_type=${log_type}&
						inquirypatientId=${patientId}&patientIM=${patientImId}`)
				}
			}
			/**
			 * TODO
			 * 会诊监听
 			 * @param res
			 */
			consultationSocket.onMessage = function (res) {
				console.log(res, '会诊消息数据chat');
				switch (res.code) {
					case 1:
						consultationSocketConfig = {
							...(res.configuration || {}),
						}
						break;
					case 3: // 会诊开始
						handleConsultationStart(res);
						break;
					case 6: // 医生离开
						handleConsultationEnd(res);
						break;
					default:
						// 其他消息类型
						break;
				}
			}
			$('.changeList').on("click", function () {
				$(this).find('span').addClass('icon_Active').siblings('.icon_Active').removeClass(
					'icon_Active');
				console.log($(this).find('span'))
				department_id = $(this).attr('id');
				no = $(this).data('no');
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					// goPage('inquiry_doctor.htm');
					var strGoUrl = 'inquiry_doctor.htm?log_type=' + log_type + '&department_id=' +
						department_id + '&no=' + no;
					goPage(strGoUrl);
				}
			})
			//点击咨询进入医生主页
			$(".advisory").on("click", function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					// newGetConsultationFee()
					// if (haveFee == 0) {

					goPage('doctor_home_page.htm?doctor_id=' + $(this).attr("id"))

					// } else {

					// }
				}

			});
			//跳转到全科页面
			$(".toList").on("click", function () {
				no = $(this).data('no');
				department_id = $(this).data('id');
				console.log(log_type)
				console.log(department_id)

				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				}
				// goPage('inquiry_doctor.htm');
				var strGoUrl = 'inquiry_doctor.htm?log_type=' + log_type + '&department_id=' + department_id +
					'&no=' + no;
				goPage(strGoUrl);
			});
			// 跳转到专家页面
			$('#expert_clinic').click(function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					goPage('inquiry_doctor.htm');
				}
				// goPage('inquiry_doctor.htm');
			})
			// 跳转到网络问诊页面
			$('#my_consult').click(function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					if (!isFreeBilling) { // 非橙实医院
						goPage('my_inquiry.htm?user_id=' + getUserId());
					} else { // 橙实医院
						goPage('inquiry_self_invoicing.htm')
					}
				}
				// goPage('my_inquiry.htm?user_id='+getUserId());
			})
			//1.65版本代码
			// 跳转到我的处方
			$('#my_prescription').click(function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					goPage("recipe_list.htm?user_id=" + getUserId());
				}
				// goPage("recipe_list.htm?user_id="+getUserId());
			})
			// 跳转到我的订单
			$('#my_order').click(function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					// goPage("recipe_list.htm?user_id="+getUserId());
					goPage('user_list.htm?orgid=' + orgid + '&openid=' + openid + '&user_id=' + user_id +
						'&isIndex=1');
				}
				// goPage("recipe_list.htm?user_id="+getUserId());
			})

			// 跳转到复诊问诊页面
			$('#follow-up').click(function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					// goPage("recipe_list.htm?user_id="+getUserId());
					goPage('inquiry_doctor.htm?fromFollowUp=1');
				}
				// goPage("recipe_list.htm?user_id="+getUserId());
			})


			// 跳转到体质检测页面
			$('#physical_examin').click(function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					newAjaxPost("/h5/home/getConstitution", {}, (json) => {
						if (json.data.isValid == 1) {
							goPage("user_physical_examin.htm?user_id=" + getUserId());
						} else {
							msgInfo("该功能暂未开通")
						}
					})
				}
				// goPage("recipe_list.htm?user_id="+getUserId());
			})

			$('.weui-search-bar__box').on('focus', 'input', function () {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					goPage("inquiry_search.htm");
				}
			})
			$('.go-search').click(() => {
				if (!isLogin()) { //判断是否登录
					$.confirm("请先登录再操作", function () {
						goPage('login.htm');
					}, function () {
						//取消操作
					});
				} else {
					goPage("inquiry_search.htm");
				}
			})
		});


		//获取首页轮播图
		function newGetBannerList() {
			newAjaxPost("/h5/banner/getBannerList", {}, newGetBannerListOk);
		}

		function newGetBannerListOk(jsonInfo) {
			var data;
			var BannerListData = '';
			if (jsonInfo.code == 1) {
				data = jsonInfo.data.list;
				for (var i = 0; i < data.length; i++) {
					BannerListData += `<div class="swiper-slide"><img src="${data[i].img}" alt=""></div>`;
				}
				$('.swiper-wrapper').html(BannerListData);
			}
		}


		//获取首页轮播图
		function newGetBannerList() {
			newAjaxPost("/h5/banner/getBannerList", {}, newGetBannerListOk);
		}

		function newGetBannerListOk(jsonInfo) {
			var data;
			var BannerListData = '';
			if (jsonInfo.code == 1) {
				data = jsonInfo.data.list;
				for (var i = 0; i < data.length; i++) {
					BannerListData += `<div class="swiper-slide"><img src="${data[i].img}" alt=""></div>`;
				}
				$('.swiper-wrapper').html(BannerListData);
			}
		}
		//获取首页科室
		function newGetDepartmentList() {
			newAjaxPost("/h5/index/utilDepartment/getDepartmentListPc", {}, newGetDepartmentListOk);
		}

		function newGetDepartmentListOk(jsonInfo) {
			var data;
			// console.log(jsonInfo);
			var seleListData = '';
			if (jsonInfo.code == 1) {
				data = jsonInfo.data.list;
				// console.log(data);
				if (data.length < 8) {
					for (var i = 1; i < data.length; i++) {
						seleListData +=
							`<a href="#" class="changeList" data-no="${i}" id="${data[i].id}" ><img class="iconfont" src="${data[i].icon || defaultDepartment}" onerror="picError(this)">${data[i].departmentName}</a>`;
					}
				} else {
					for (var i = 1; i < 8; i++) {
						seleListData +=
							`<a href="#" class="changeList" data-no="${i}" id="${data[i].id}" ><img class="iconfont" src="${data[i].icon || defaultDepartment}" onerror="picError(this)">${data[i].departmentName}</a>`;
					}
				}
				seleListData +=
					` <a href="#" class="changeList" data-no="7" id="0" ><img class="iconfont" src="${data[0].icon || defaultDepartment}">${data[0].departmentName}</a>`;
				$('#seleList').html(seleListData);
			}
		}

		// 获取首页医生
		function newGetHomeDoctorList() {
			var params = {
				"current": 1,
				"departmentId": 0,
				"keyWord": "",
				"size": 100
			}
			newAjaxPost("/h5/doctorInfo/getHomeDoctorList", params, newGetHomeDoctorListOk);
		}

		function newGetHomeDoctorListOk(jsonInfo) {
			// console.log(jsonInfo);
			var doctorListData = '';
			var doctorListData2 = '';
			var doctNums;
			var data;
			var userJson = getUserInfo();
			h5token = userJson.h5Token
			userid = userJson.id;
			usertype = userJson.type;
			if (jsonInfo.code == 1) {
				data = jsonInfo.data.list;
				if (data.length > 0) {
					doctNums = data.length;
					for (var i = 0; i < data.length; i++) {
						if (data[i].isOnline == 1) { //是否在线  0否  1是
							if (doctNums != 0) {
								doctorListData += '<div class="expertlist_map" >';
								doctorListData += '<div class="expertlist_map_top to_detail" num="0" id="' + data[i].id +
									'" >';
								doctorListData += '<div class="expertlist_map_img"> <img src="' + data[i].doctorHeadImg +
									'" /> </div>';
								doctorListData += '<div class="doctor_info">';
								doctorListData += '<div class="doctor_name">' + data[i].trueName + '<span>' + data[i]
									.doctorJobTitle + '</span>   <span style="padding:5px 5px">' + data[i].departmentName +
									'</span><span class="isOnline" style="padding:5px 5px">在线</span></div>';
								doctorListData += '<div class="age">从业年限 <span>' + data[i].workAge + '年</span> 　年龄 <span>' +
									data[i].doctorAge + '岁</span></div>';
								doctorListData += '</div>';
								doctorListData += '</div>';
								doctorListData +=
									'<div style="word-break:break-all" class="brief_introduction uni-ellipsis-2 to_detail" num="0" id="' +
									data[i].id + '">' + data[i].doctorSynopsis + '</div>';
								doctorListData +=
									'<div class="view_felx home_icon_img" style="display:flex;-ms-flex-align: center;justify-content: center;">';
								doctorListData += '<div class="advisory" id="' + data[i].id +
									'" style="border:none;text-align: center;font-weight: bold;">立即咨询</div>';
								doctorListData += '</div>';
								doctorListData += '</div>';
								doctNums--;
							}
						}
						if (data[i].isOnline == 0) {
							if (doctNums != 0) {
								doctorListData2 += '<div class="expertlist_map"  num="0" id="' + data[i].id + '">';
								doctorListData2 += '<div class="expertlist_map_top to_detail" num="0" id="' + data[i].id +
									'" >';
								doctorListData2 += '<div class="expertlist_map_img"> <img src="' + data[i].doctorHeadImg +
									'" /> </div>';
								doctorListData2 += '<div class="doctor_info">';
								doctorListData2 += '<div class="doctor_name">' + data[i].trueName + '<span>' + data[i]
									.doctorJobTitle + '</span>   <span style="padding:5px 5px">' + data[i]
									.departmentName +
									'</span><span class="noOnline" style="padding:5px 5px">离线</span></div>';
								doctorListData2 += '<div class="age">从业年限 <span>' + data[i].workAge +
									'年</span> 　年龄 <span>' + data[i].doctorAge + '岁</span></div>';
								doctorListData2 += '</div>';
								doctorListData2 += '</div>';
								doctorListData2 +=
									'<div style="word-break:break-all" class="brief_introduction uni-ellipsis-2 to_detail" num="0" id="' +
									data[i].id +
									'">' + data[i].doctorSynopsis + '</div>';
								doctorListData2 +=
									'<div class="view_felx home_icon_img" style="display:flex;-ms-flex-align: center;justify-content: center;">';
								doctorListData2 += '<div class="advisory" id="' + data[i].id +
									'" style="border:none;text-align: center;font-weight: bold;">立即咨询</div>';
								doctorListData2 += '</div>';
								doctorListData2 += '</div>';
								doctNums--;
							}
						}
					}
				}
				//console.log(doctorListData)
				$('#doctorList').html(doctorListData + doctorListData2);

				//跳转到医生页面
				$(".to_detail").on("click", function () {
					log_type = $(this).attr('num');
					doctor_id = $(this).attr('id');
					if (!isLogin()) { //判断是否登录
						$.confirm("请先登录再操作", function () {
							goPage('login.htm');
						}, function () {
							//取消操作
						});
					} else {
						// newGetConsultationFee()
						// if (haveFee == 0) {
						var strGoUrl = 'doctor_home_page.htm?log_type=' + log_type + '&doctor_id=' + doctor_id;
						goPage(strGoUrl);

						// } else {

						// }
					}
				});
				//视频、图文问诊
				$(".inquiryBtn").on("click", function () {
					log_type = $(this).attr('num'); //问诊类型：1视频 2图文
					doctor_id = $(this).attr('id'); //医生id
					doctor_name = $(this).attr('docname');
					fee_pay = $(this).attr('pay');
					if (!isLogin()) { //判断是否登录
						$.confirm("请先登录再操作", function () {
							goPage('login.htm');
						}, function () {
							//取消操作
						});
					} else {
						var strGoUrl;
						if (haveFee == 0) { //没付问诊费
							strGoUrl = 'inquiry_doctor_fee.htm?feepay=' + fee_pay + '&log_type=' + log_type +
								'&doctor_id=' + doctor_id + '&doctor_name=' + doctor_name;
							goPage(strGoUrl);
						} else { //已付问诊费
							if (haveFeeDoctorName == doctor_name && log_type == haveFeeLogType) { //已付费的那个医生的指定问诊
								strGoUrl = 'inquiry_doctor_patient.htm?log_type=' + log_type + '&doctor_id=' +
									doctor_id + '&h5_token=' + h5token + '&user_id=' + userid + '&user_type=' +
									usertype;
								goPage(strGoUrl);
							} else if (haveFeeDoctorName == doctor_name && log_type != haveFeeLogType) {
								$.alert("您购买的是该医生的另一种问诊！", function () {
									return;
								});
							} else { //不是已付费的那个医生，禁止问诊
								$.alert("本日之内您还有其他医生的问诊没结束，请先完成问诊！", function () {
									return;
								});
							}
						}
					}
				});
				$('.offline').on("click", function () {
					$.alert({
						title: '温馨提示',
						text: '当前医生离线，请选择其他医生',
						onOK: function () {
							//点击确认
						}
					});
				})

				//查看医生值班计划
				$(".schedulingBtn").on("click", function () {
					if (!isLogin()) { //判断是否登录
						$.confirm("请先登录再操作", function () {
							goPage('login.htm');
						}, function () {
							//取消操作
						});
					} else {
						log_type = $(this).attr('num');
						doctor_id = $(this).attr('id');
						goPage('inquiry_doctor_sche.htm?doctor_id=' + doctor_id + "&rand=" + Math.random());
					}
					// log_type = $(this).attr('num');
					// doctor_id = $(this).attr('id');
					//    goPage('inquiry_doctor_sche.htm?doctor_id=' + doctor_id+ "&rand=" + Math.random());
				});
				setTimeout(function () {
					newGetHomeDoctorList();
				}, 12000);
			} else {
				msgInfo('正在加载医生中');
				setTimeout(function () {
					newGetHomeDoctorList();
				}, 1500);
			}
		}
		//获取用户订单
		function newGetConsultationFee() {
			if (!isLogin()) { //判断是否登录
				// 不获取
			} else {
				newAjaxPost("/h5/wxpay/getConsultationFee", {}, newGetConsultationFeeOk);
			}
		}

		function newGetConsultationFeeOk(jsonInfo) {
			var data, time = null;
			// console.log(jsonInfo);
			if (jsonInfo.code == 1) {
				data = jsonInfo.data;
				if (data) {
					if (data.inquiryType == 1 || data.inquiryType == 2) {
						EndTime = data.payEndTime
						timer = setInterval(updateTime, 1000);
						updateTime();
						haveFee = 1;
						haveFeeLogType = data.inquiryType;
						var doctorInquiryType = data.doctorInquiryType;
						haveFeeDoctorName = data.trueName;
						var feeinfo = '',
							feeinfodate = '',
							feeinfoselect = '',
							inquiry = '';
						if (data.isOnline == 1) {
							feeinfo += '<div class="is_online"><img src="../res/images/img_on_line.png" /></div>';
						} else {
							feeinfo += '<div class="is_online"><img src="../res/images/img_off_line.png" /></div>';
						}
						if (data.inquiryType == 2) {
							inquiryType = '图文问诊'
						} else if (data.inquiryType == 1) {
							inquiryType = '视频问诊'
						} else {}
						feeinfo += '<div class="expertlist_map_top to_detail" num="0" id="' + data.doctorId + '" >';
						feeinfo += '	<div class="expertlist_map_img"> <img src="' + data.doctorHeadImg + '" /> </div>';
						feeinfo += '	<div class="doctor_info">';
						feeinfo += '		<div class="doctor_name">' + data.trueName + '<span>' + data.doctorJobTitle +
							'</span>   <span>' + data.departmentName + '</span></div>';
						feeinfo += '		<div class="age" style="text-align: left; ">从业年限 <span>' + data.workDate +
							'年</span> 年龄 <span>' + data.age + '岁</span></div>';
						feeinfo += '	</div>';
						feeinfo += '</div>';
						feeinfodate += '您已购买 <span>' + data.trueName + '医生</span> 的 <span>' + inquiryType +
							'</span> 诊查费，请在有效时间内向医生发起问诊。若要更换问诊方式，请先退诊查费再重新购买。'
						feeinfodate += '<div id="start">';
						feeinfodate += '	剩余时间<span id="hour">00</span>:<span id="min">00</span>:<span id="sec">00</span>';
						feeinfodate += '</div>';
						feeinfoselect +=
							'<a href="javascript:;" class="weui-dialog__btn default removeDialog">取消</a><a href="javascript:;" class="weui-dialog__btn primary torefee" id="' +
							data.doctorId + '">退诊查费</a><a href="javascript:;" class="weui-dialog__btn primary toWrite" id="' +
							data.doctorId + '">发起问诊</a>'
						$('.feeInfo').html(feeinfo);
						$('.feeInfoDate').html(feeinfodate);
						$('.feeInfoSelect').html(feeinfoselect);
						$('.weui-mask').addClass('weui-mask--visible')
						$('.weui-dialog').addClass('weui-dialog--visible')
					} else {
						haveFee = 0
					}
				}
			}
			$('.toWrite').on('click', function () {
				if (jsonInfo.data.isOnline == 0) {
					msgInfo('医生不在线！');
					return
				}
				doctor_id = $(this).attr('id'); //医生id
				// strGoUrl = 'inquiry_doctor_detail.htm?doctor_id=' + doctor_id ;
				// goPage(strGoUrl);
				if ((doctorInquiryType == 1 && haveFeeLogType == 2) || (doctorInquiryType == 2 && haveFeeLogType ==
						1)) { //问诊类型不对
					msgInfo('该医生当前不支持' + inquiryType);
				} else {
					strGoUrl = 'inquiry_doctor_patient.htm?log_type=' + haveFeeLogType + '&doctor_id=' + doctor_id +
						'&h5_token=' + h5token + '&user_id=' + userid + '&user_type=' + usertype;
				}
				goPage(strGoUrl);
			})
			$(".torefee").on('click', function () {
				doctor_id = parseInt($(this).attr('id')); //医生id
				$('#androidDialog1').fadeIn(200);
				// var params = {
				//   "doctorId": doctor_id,
				//   // "userId": getUserId(),
				// }
				// newAjaxPost("/h5/wxpay/refund", params, newRefeeOk);
			})
			$('.removeDialog').on('click', function () {
				$('.weui-mask').removeClass('weui-mask--visible')
				$('.weui-dialog').removeClass('weui-dialog--visible')
			})
			$('.weui-dialog__btn_primary').on('click', function () {
				var params = {
					"doctorId": doctor_id,
					"isFrozen": 0
				}
				newAjaxPost("/h5/wxpay/refund", params, newRefeeOk);
			})
			$('.weui-dialog__btn_default').on('click', function () {
				$('#androidDialog1').fadeOut(200);
			})
		}

		function newRefeeOk(jsonInfo) {
			if (jsonInfo.code == 1) {
				// msgInfo('退费成功，请重新选择医生问诊');
				setTimeout(function () {
					location.reload()
				}, 1000);
			}
		}

		function updateTime() {
			var oEndDate = new Date(EndTime.replace(/-/g, '/'))
			var oNowDate = new Date();
			var iRemain = 0;
			iRemain = parseInt((oEndDate.getTime() - oNowDate.getTime()) / 1000);
			iRemain %= 86400;
			var iHour = parseInt(iRemain / 3600); //剩余小时
			iRemain %= 3600;
			var iMin = parseInt(iRemain / 60); //剩余分钟
			iRemain %= 60;
			var iSec = iRemain; //剩余秒
			$('#hour').html(fillZero(iHour, 2));
			$('#min').html(fillZero(iMin, 2));
			$('#sec').html(fillZero(iSec, 2));
		}

		function fillZero(num, digit) {
			var str = '' + num;
			if (str.length < digit) {
				str = '0' + str;
			}
			return str;
		}

		// 科室图片加载失败
		function picError(el) {
			// console.log(el)
			el.src = defaultDepartment
		}
	</script>
</head>

<body ontouchstart>
	<div class="fixed-top">
		<div class="weui-btn_primary weui-header">
			<!-- <div class="weui-header-left"><a class="icon icon-109 f-white"></a>  </div> -->
			<h1 class="weui-header-title"></h1>
			<div class="weui-header-right">
				<!-- <a class="icon icon-81 f-white iblock"></a>筛选 -->
			</div>
		</div>
	</div>
	<div style="padding-top: 46px;padding-bottom: 56px;">
		<!-- 搜索框 -->
		<div class="weui-search-bar weui-search-bar_focusing" id="searchBar">
			<form class="weui-search-bar__form" action="#">
				<div class="weui-search-bar__box">
					<i class="weui-icon-search"></i>
					<input class="weui-search-bar__input" id="searchInput" placeholder="搜索科室，医生，疾病" required=""
						type="search" autocomplete="off">
				</div>
			</form>
		</div>

		<div id="user-name" style="display: flex; justify-content: space-between; margin: 15px 15px 0 15px;">
			<div id="userName">您好！</div>
			<div class="go-search"><img style="width: 20px; height: 20px;" src="../res//images/search.png" alt=""></div>
		</div>
		<!-- <div style="padding: 10px;">
			仅调试时使用
			<input type="text" onblur="eval($(this).val())">
		</div> -->
		<!--轮播图-->
		<div class="swiper-container">
			<div class="swiper-wrapper">
				<div class="swiper-slide">
					<img src="https://yixiang-hospital.oss-cn-shenzhen.aliyuncs.com/mini/minImg/img_banner.png"alt="">
				</div>
			</div>
			<div class="swiper-pagination"></div>
		</div>
		<div class="weui-cells">
			<!-- 选择按钮 -->
			<div class="index_butList">
				<div class="weui-grids" id="seleList">
				</div>
			</div>

		</div>
		<!-- 个别按钮 -->
		<div class="header_btn">
			<!-- 1.65版本代码 -->
			<div id="my_consult">
				<img class="consult_img" src="../res/images/img_consultation.png" alt="">
				<div class="self_invoicing">
					<p style="font-size: 20px;">自助开单</p>
					<p style="font-size: 14px;">SELF INVOICING</p>
				</div>
			</div>
			<!-- 体质检测入口隐藏 -->
			<!-- <div id="physical_examin">
				<div><img src="../res/images/img_constitution.png" alt=""></div>
			</div> -->
			<div id="follow-up">
				<img src="../res/images/img_follow_up_visit.png" alt="">
			</div>
			<div id="my_prescription">
				<img src="../res/images/img_prescription.png" alt="">
			</div>
			<div id="my_order">
				<img src="../res/images/img_order.png" alt="">
			</div>
			<div id="expert_clinic">
				<img src="../res/images/img_expert.png" alt="">
			</div>
		</div>

		<div class="weui-cells">
			<!-- <span class="seldoc">请选择医生<span style="color: #aaaaaa;">（请优先选择在线医生）</span></p> -->
			<!-- 选择按钮 -->
			<!-- <div class="index_butList">
			<div class="weui-grids" id="seleList">
			</div>
		</div> -->
			<div class="index_title">
				<div id="round1"></div>权威专家 <div id="round2"></div> <span>丨 为您推荐权威医生</span>
			</div>
			<!-- 选择列表 -->
			<div class="index_manList">
				<div class="weui-grids" id="doctorList">
				</div>
			</div>
		</div>

		<!-- 问诊订单查询 -->
		<div class="weui-mask" style="opacity: 1;"></div>
		<div class="weui-dialog" style="opacity: 1;">
			<div class="expertlist_map feeInfo" style="border-radius: 0px;">

			</div>
			<div class="weui-dialog__bd feeInfoDate"></div>
			<div class="weui-dialog__ft feeInfoSelect">
				<a href="javascript:;" class="weui-dialog__btn default">取消</a>
				<a href="javascript:;" class="weui-dialog__btn primary">确定</a>
			</div>
		</div>
		<div class="js_dialog" id="androidDialog1" style="display: none;">
			<div class="weui-mask"></div>
			<div class="weui-dialog weui-skin_android">
				<div class="weui-dialog__hd"><strong class="weui-dialog__title">您确认要退诊查费吗?</strong></div>
				<div class="weui-dialog__bd">
					当前问诊费会在1-3个工作日原路返回，请耐心等待
				</div>
				<div class="weui-dialog__ft">
					<a href="javascript:" class="weui-dialog__btn weui-dialog__btn_default">取消</a>
					<a href="javascript:" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
				</div>
			</div>
		</div>
		<!--脚部-->
		<div id='tb' class="weui-tab" style="height:auto;">
			<div class="weui-tabbar tab-bottom">
				<a href="javascript:;" class="weui-tabbar__item" id="inquiry_index">
					<span style="display: inline-block;position: relative;">
						<img src="../res/images/index_icon.png" alt="" class="weui-tabbar__icon">
					</span>
					<p class="weui-tabbar__label f-blue">首页</p>
				</a>
				<a href="javascript:;" class="weui-tabbar__item" id="inquiry_doctor">
					<img src="../res/images/acitve_wz.png" alt="" class="weui-tabbar__icon">
					<p class="weui-tabbar__label">问诊</p>
				</a>
				<a href="javascript:;" class="weui-tabbar__item" id="my_doctor_index">
					<span style="display: inline-block;position: relative;">
						<img src="../res/images/icon_doctor.png" class="weui-tabbar__icon">
					</span>
					<span id="unreadIcon" style="display: none;"></span>
					<p class="weui-tabbar__label ">我的医生</p>
				</a>
				<a href="javascript:;" class="weui-tabbar__item" id="inquiry_user_per">
					<img src="../res/images/active_per.png" class="weui-tabbar__icon">
					<p class="weui-tabbar__label">我的</p>
				</a>
			</div>
		</div>
</body>

</html>
